Introduction
The for loop is a statement which allows code to be repeatedly executed. A for loop contains three parts: Initialization, Condition, and Increment or Decrement.
Steps of Execution
- First, initialize the variable. This executes only once when entering the loop for the first time.
- In the second step, check the condition.
- In the third step, control goes inside the loop body and executes.
- Finally, increase or decrease the value of the variable.
- The same process repeats until the condition is false.
For Loop Flowchart
(Insert flowchart here)
For Loop Syntax
for(Initialization; Test Condition; increment/decrement)
{
Loop Body;
}